home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 4490 / 4490.xpi / components / scripts / aol.js next >
Text File  |  2010-01-07  |  3KB  |  100 lines

  1. /***********************************************************
  2. AOL
  3. ***********************************************************/
  4. var supportInboxOnly=true;
  5.  
  6. function init(){
  7.   this.initStage=ST_PRE;
  8.   this.loginData=["https://my.screenname.aol.com/_cqr/login/login.psp"];
  9.   this.dataURL="http://webmail.aol.com/Lite/MsgList.aspx?showUserFolders=True";
  10.   this.mailURL="http://webmail.aol.com/";
  11.   this.mailDomain="webmail.aol.com";
  12. }
  13. function getCount(aData){
  14.   return this.mailCount;
  15. }
  16. function getCount0(aData){
  17.   var fnd=aData.match(/setMessageCounts\((\d+)/);
  18.   if(fnd){
  19.     return fnd[1];
  20.   }else{
  21.     return -1;
  22.   }
  23. }
  24. function getCount1(aData){
  25.   var re=/<div class=\"navItem userFolder.+?<\/div>.+?(?:\((\d+)\))?<\/a><\/div>/g;
  26.   var o;
  27.   var num=0;
  28.   while ((o = re.exec(aData)) != null){
  29.     if(o[1])num+=parseInt(o[1]);
  30.   }
  31.   return num;
  32. }
  33.  
  34. function process(aHttpChannel, aData) {
  35.   switch(this.stage){
  36.   case ST_PRE:
  37.     this.getHtml("http://webmail.aol.com");
  38.     return false;
  39.   case ST_PRE_RES: 
  40.     var fnd=aData.match(/<iframe.+id\s*=\s*[\"\']snsModule[\"\'].+src=\"(\S+?)\"/);
  41.     if(fnd){
  42.       this.getHtml(fnd[1]);
  43.       return false;
  44.     }
  45.   case ST_PRE_RES+1:
  46.     var reg=new RegExp("<form.+name\\s*=\\s*[\"\']AOLLoginForm[\"\']([\\S\\s]+?)<script");
  47.     var s=aData.match(reg); 
  48.     if(s){
  49.       s=s[1].match(/<input.+?[^-]>/g);
  50.       var post="";
  51.       for(var i in s){
  52.         var t=s[i].match(/<input.+name\s*=s*[\"\'](\S+)[\"\'].+value\s*=\s*[\"\'](\S*)[\"\']/);
  53.         if(t){
  54.           if(post)post+="&";
  55.           post+=t[1]+"="+encodeURIComponent(t[2]);
  56.         }
  57.       }
  58.       this.loginData[LOGIN_DATA]=post;
  59.     }
  60.     this.stage=ST_LOGIN;
  61.   case ST_LOGIN:
  62.     var ar=this.user.split("@");
  63.     var user=this.user;
  64.     if(ar[1]=="aol.com" || ar[1] =="aim.com" || ar[1]=="netscape.net" || ar[1] =="aol.fr" || ar[1] =="aol.de" || ar[1] =="cs.com" || ar[1]=="aol.co.uk") {
  65.       user=ar[0];
  66.     }    
  67.     this.loginData[LOGIN_POST]="loginId="+encodeURIComponent(user)
  68.                                 +"&password="+encodeURIComponent(this.password);
  69.     this.getHtml(this.loginData[LOGIN_URL],this.loginData[LOGIN_POST]+"&"+this.loginData[LOGIN_DATA]);
  70.     return false;
  71.   case ST_LOGIN_RES:
  72.     var fnd=aData.match(/checkErrorAndSubmitForm\(.+?,.+?,\s*?\'(\S+?)\'/);
  73.     if(fnd){
  74.       this.getHtml(fnd[1]);
  75.       return false;
  76.     }
  77.     break;
  78.   case ST_LOGIN_RES+1:
  79.     this.stage=ST_DATA;
  80.    case ST_DATA:
  81.     this.getHtml("http://webmail.aol.com/Lite/MailCounts.aspx");
  82.     this.stage=ST_DATA_RES+1;    
  83.     return true;
  84.   case ST_DATA_RES+1:
  85.     this.mailCount=parseInt(this.getCount0(aData));
  86.     if(this.inboxOnly||this.mailCount<0){
  87.       this.stage=ST_DATA_RES;
  88.       break;
  89.     }else{
  90.       this.getHtml(this.dataURL);
  91.       return false;
  92.     }
  93.   case ST_DATA_RES+2:  
  94.     this.mailCount+=parseInt(this.getCount1(aData));
  95.     this.stage=ST_DATA_RES;
  96.     break;
  97.   }
  98.   return this.baseProcess(aHttpChannel, aData);
  99. }
  100.